<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
  <title>简知后台管理</title>
  <link rel="stylesheet" href="static/common/layui/css/layui.css">
  <script src="static/common/jquery-3.3.1.min.js"></script>
  <style>
      .head_nav,.shu_nav,.left_nav,.nav_side{
          background-color: lightgray !important;
      }
      .head_nav{
          border-bottom: 1px solid lightseagreen;
      }
      .layui-nav .layui-nav-item a:hover{
          background-color: gray;
      }
      .tips{
        position: fixed;
        top: 0;
        width: 99%;
        height: 55px;
        z-index: 999;
        border-radius: 6px;
        margin-left: 0.5%;
        text-align: center;
        line-height: 55px;
      }
  </style>
</head>
<body class="layui-layout-body">
<div class="layui-layout layui-layout-admin">
  <div class="layui-header head_nav">
    <div class="layui-logo">简知管理后台</div>
    <ul class="layui-nav layui-layout-right">
      <li class="layui-nav-item">
        <a href="javascript:;">
          <img src="static/system/img/head_img/head.jpg" class="layui-nav-img">
          <span id="userName"></span>
        </a>
      </li>
      <li class="layui-nav-item"><a id="logout" href="javascript:void(0);" >goodBye</a></li>
    </ul>
  </div>
  
  <div class="layui-side layui-bg-black">
    <div class="layui-side-scroll nav_side">
      <!-- 左侧导航区域（可配合layui已有的垂直导航） -->
      <ul class="layui-nav layui-nav-tree left_nav"  lay-filter="test">
        <li class="layui-nav-item layui-nav-itemed left_item">
          <a href="javascript:;">用户管理</a>
          <dl class="layui-nav-child">
            <dd><a id="userIframe" href="javascript:;">用户详情</a></dd>
            <dd><a id="" href="javascript:;">用户权限</a></dd>
          </dl>
        </li>
        <li class="layui-nav-item left_item">
          <a href="javascript:;">文章管理</a>
          <dl class="layui-nav-child">
            <dd><a id="articleIframe" href="javascript:;">文章详情</a></dd>
            <dd><a id="garbageIframe" href="javascript:;">回收站</a></dd>
          </dl>
        </li>
      </ul>
    </div>
  </div>
  
  <div class="layui-body" style="overflow: hidden;">
    <!-- 内容主体区域 -->
    <div id="iframewrap" style="padding: 2px 15px 15px;width: 100%;height: 100%;">
    </div>
  </div>
  
  <div class="layui-footer" style="text-align:center;">
    <!-- 底部固定区域 -->
    © article_manager--文章管理
  </div>
</div>
<script src="static/common/layui/layui.js"></script>
<script>
   $(document).ready(function(){
      getSession();//获取session信息
      logout();//注销用户
      changeIframe('userIframe','userInfo_manager.html');//切换到用户详情
      changeIframe('articleIframe','articleInfo_manager.html');//切换到文章详情
      changeIframe('garbageIframe','garbage_manager.html');//切换到文章回收站
   });
   function changeIframe(iframeId,iframeSrc){
      $('#'+iframeId).click(function(){
          $('#iframewrap').html('<iframe style="width: 96%;height: 100%;border: none;" src='+iframeSrc+'></iframe>');
      });
   }
  //JavaScript代码区域
  layui.use('element', function(){
    var element = layui.element;
    
  });
  /*获取session用户信息值*/
  function getSession(){
    fetch('/article_manager_module/getMangerInfo', {
      method: 'GET',
      headers: new Headers({
        'Content-Type': 'application/json;charset=utf-8'
      })
    }).then(res => res.json()).catch(error => console.error(error))
    .then(function(response){
      $('#userName').html(response.data.mName);
    });
  }
  /*logout注销登录*/
  function logout(){
    $('#logout').on('click',function(){
      fetch('/article_manager_module/mlogout', {
        method: 'GET',
        headers: new Headers({
          'Content-Type': 'application/json;charset=utf-8'
        })
      }).then(res => res.json()).catch(error => console.error(error))
      .then(function(response){
            window.location.href="http://localhost/article_manager_login.html";
        });
    });
  }
</script>
</body>
</html>